import { useState } from "react";

const Form = () => {
  const [isSent, setIsSent] = useState(false);
  const [message, setMessage] = useState("Hi !");
  if( isSent ) {
	  return (
		  <div>
			  <h1>Thank you!</h1>
			  <p>We'll be in touch soon.</p>
		  </div>
	  );
  }
  return (
	  <form onSubmit={(e) => {
		  e.preventDefault();
		  setIsSent(true);
		  sendMsg(message);
	  }}>
		  <label htmlFor="message">Message:</label>
		  <textarea id="message" value={message} onChange={(e) => setMessage(e.target.value)} />
		  <button type="submit">Send</button>
	  </form>
  );
}


const sendMsg = (msg :string) => {
  console.log("Sending message:", msg);
};
export default Form;